package bookManager;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        User user=login();
        while (true){
            int choice=user.menu();
            user.doOperation(choice);

        }
    }

    private static User login() {
        Scanner scanner=new Scanner(System.in);
        System.out.println("输入用户名：");
        String userName=scanner.next();
        System.out.println("输入密码：");
        String password=scanner.next();
        UserDao userDao=new UserDao();
        User user=userDao.findUserByName(userName);
        if(user==null){
            System.out.println("用户或密码不存在！");
            System.exit(0);
        }
        if(!user.getPassword().equals(password)){
            System.out.println("用户名或密码错误！");
            System.exit(0);
        }
        return user;
    }
}
